//
//  QLNiceNetworkTools.m
//  Nice
//
//  Created by huangyueqi on 2017/8/1.
//  Copyright © 2017年 sjyt. All rights reserved.
//

#import "QLNiceNetworkTools.h"

@implementation QLNiceNetworkTools

+ (instancetype)sharedTools {
    
    static QLNiceNetworkTools *tools;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        tools = [[QLNiceNetworkTools alloc] init];
        tools.responseSerializer.acceptableContentTypes = [tools.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
    });
    return tools;
}

- (void)requestWithUrl:(NSString *)url andParams:(id)params andCallBack:(void (^)(id response, NSError *error))callBack {
    
    [self POST:url parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        callBack(responseObject, nil);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        callBack(nil, error);
    }];
}


@end
